<?php
/*注意需要重新加载一下jquery.easyui.min.js,否则easyui的validatebox验证不起作用。不能重新加载jquery.js，否则会无法关闭当前dialog和重新reload datagrid*/
?>
<script type="text/javascript" src="<?php echo base_url(); ?>/includes/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
			$(document).ready(function() {
				
				$('#add_admin_form').form( {
					url:'<?php echo site_url("user/user/add"); ?>',
					onSubmit : function() {
						//alert($(this).form('validate'));
						return $(this).form('validate');	
					},
					success : function(data) {
						if (data == "succ") {
							$.messager.alert('<?php echo $this->lang->line("system_prompt"); ?>', '<?php echo $this->lang->line("added_success"); ?>！', 'info');
							$('#add_record').window("close");
							$('#test').datagrid('reload');
						} else {
							$.messager.alert('<?php echo $this->lang->line("system_prompt"); ?>', data, 'error');
						}
					}
				});
				
				//ajax检查用户名是否已存在
				$("#check_username_exist").hide();
				$("#username").blur(function(){
					$("#check_username_exist").hide();
					var name =  $("#username").val();
					var data = 'uname='+name+'&uid='+0;
					//alert(data);
					$.ajax({
						type:"POST",
						url:'<?php echo site_url("user/user/check_username_exist"); ?>',
						data: data,
						success:function(html){
							//alert(html);
							$("#check_username_exist").show();
							$("#check_username_exist").text(html);
						}
					});
					
					
					
		
				});

				
			});
</script>	

<style type="text/css">
.label
{
	float:left; width:100px;	
}

.unit
{
	margin:10px;
}

</style>
    
    <form method="post"  id="add_admin_form" >
		

			
            <div class="unit">
            	<label class="label"><?php echo $this->lang->line("system_user_lastname"); ?>：</label>
                <input type="text" class="easyui-validatebox" required="true" validType="length[1,20]"  size="30" maxlength="200" name="lastname" value="" />
            </div>
            <div class="unit">
            	<label class="label"><?php echo $this->lang->line("system_user_firstname"); ?>：</label>
                <input type="text" class="easyui-validatebox" required="true" validType="length[1,20]"  size="30" maxlength="200" name="firstname" value="" />
            </div>
            <div class="unit">
            	<label class="label"><?php echo $this->lang->line("email"); ?>：</label>
                <input type="text" class="easyui-validatebox" validType="email" required="true" size="30" maxlength="200" name="email" value="" />
            </div>
            <div class="unit">
				<label class="label"><?php echo $this->lang->line("username"); ?>：</label>
				<input type="text" class="easyui-validatebox"  required="true" validType="length[3,10]"  size="30" maxlength="30" name="username" id="username" value="" />
                <span id="check_username_exist"></span>
			</div>
			<div class="unit">
				<label class="label"><?php echo $this->lang->line("password"); ?>：</label>
				<input type="text" name="password" class="easyui-validatebox" required="true" validType="length[5,16]"  size="30" maxlength="20" />
			</div>
			
			<div class="unit">
				<label class="label"><?php echo $this->lang->line("status"); ?>：</label>
				<select name="status">
					<option value="1"><?php echo $this->lang->line("enabled"); ?></option>
					<option value="0"><?php echo $this->lang->line("disabled"); ?></option>
				</select>
			</div>
			
			<div class="unit">
				<label class="label"><?php echo $this->lang->line("remark"); ?>：</label>
				<textarea name="remark" rows="3" cols="57"  ></textarea>
			</div>


		
			
			
		
		<div>
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit"><?php echo $this->lang->line("submit"); ?></button></div></div></li>
				
			</ul>
		</div>
	</form>
    

<?php $this->load->view("common/footer"); ?>